﻿using System;
using Microsoft.Practices.Composite.Events;
using Microsoft.Practices.Composite.Regions;
using Microsoft.Practices.Unity;

namespace Might.Infrastructure.Services {
    public static class CoreServices {
        public static IUnityContainer Container {
            get { return container; }
            set {
                if (container == null) {
                    container = value;
                    RegionManager = container.Resolve<IRegionManager>();
                    EventAggregator = container.Resolve<IEventAggregator>();
                } else {
                    throw new ArgumentException("Container can be setted only once.");
                }
            }
        }

        private static IUnityContainer container;

        public static IRegionManager RegionManager { get; private set; }
        public static IEventAggregator EventAggregator { get; private set; }
    }
}
